<template>
	<view>
		<view :style="{height:statuBarHeight+'px'}" style="width:100%;background-color:#2869FE"></view>
		<!-- 上面这个view用于占位和隔离标题栏 -->
		<view class="" style="height:441rpx;
			position: relative;">
			<view style="width:100%;height:250rpx;
			position: relative;overflow: hidden;">
				<view style="position:absolute;top:55rpx;z-index:9;
				width:100%;text-align: center;font-weight: bold;
				font-size:34rpx;color: #fff;">
					社工工作台
				</view>
				<view style="width:1500rpx;height:1500rpx;position:absolute;
				border-radius: 50%;left:-380rpx;
				bottom:-60rpx;background-color: #2869FE"></view>
				
			</view>
			<view style="width:93%;height:290rpx;position:absolute;border-radius:20rpx;transform: translateX(3.5%);
				border:1rpx solid #eee;background-color: white;bottom:10rpx;
				padding:30rpx;box-shadow: 0px 4rpx 8rpx #ddd;">
				<view style="display:flex;justify-content:space-between;
				align-items: center;">
					<view style="display: flex;">
						<image @tap="goMyInfo()" :src="userInfo.artAvatar"
						mode="aspectFill" style="width:100rpx;height:100rpx;border-radius: 50%;"></image>
						<view class="u-m-l-15">
							<view class="u-m-b-15" style="font-weight:bold;font-size:31rpx;">{{userInfo.name}}</view>
							<text v-if="isLogin==true && renZhenShow==true" style="background-color: #2869FE;
							padding: 1rpx 20rpx;color:white;border-radius:20rpx;color: #fff;
							">已认证</text>
							<text v-else style="background-color: rgb(96,211,148);
							padding: 1rpx 20rpx;color:white;border-radius:20rpx;
							">未认证</text>
							<text v-else style="background-color: red;
							padding: 1rpx 20rpx;color:white;border-radius:20rpx;
							" @tap="goLogin">去登录</text>
						</view>
					</view>
					<view class="u-m-r-20" style="display: flex;justify-content: center;align-items: center;" @tap="goMyInfo()">
						<view class="u-m-r-15" style="color:rgb(170,170,170);">个人信息</view>
						<image src="../static/qieTu/arrow-right.png" mode="widthFix"
						style="width:16rpx;height:30rpx;"></image>
					</view>
				</view>
				<view class="u-m-t-24" style="border-bottom:1px solid #ddd;transform: scaleY(0.5);"></view>
				<view class="u-m-t-28" style="display: flex;justify-content: space-around;
				font-weight: bold;text-align: center;">
					<view>
						<view class="u-font-15">{{userInfo.score}}</view>
						<view>评分</view>
					</view>
					<view>
						<view class="u-font-15">{{userInfo.jieDanLv}}</view>
						<view>接单率</view>
					</view>
					<view>
						<view class="u-font-15">{{userInfo.sucOrder}}</view>
						<view>成功接单</view>
					</view>
					<view>
						<view class="u-font-15">{{userInfo.fans}}</view>
						<view>粉丝数量</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 以上为个人信息 -->
		<view style="display: flex;padding:20rpx 30rpx;">
			<view @tap="goFuWu()" style="width:32%;background-color: rgb(255,239,239);padding:30rpx 0 20rpx 0;
			margin-right:15rpx;border-radius:10rpx;box-shadow: 0px 3px 4px #ddd;">
				<view style="display: flex;flex-direction: column;align-items: center;">
					<image src="../static/my/p8.png" mode="widthFix"
					style="width:58rpx;height:58rpx;">
					<view class="u-m-t-15">服务项目</view>
				</view>
			</view>
			<view @tap="goFuWuSet()" style="width:32%;background-color: rgb(239,241,255);padding:30rpx 0 20rpx 0;
			margin-right:15rpx;border-radius:10rpx;box-shadow: 0px 3px 4px #ddd;">
				<view style="display: flex;flex-direction: column;align-items: center;">
					<image src="../static/my/p7.png" mode="widthFix"
					style="width:58rpx;height:58rpx;">
					<view class="u-m-t-15">服务设置</view>
				</view>
			</view>
			<view @tap="goQianBao()" style="width:32%;background-color:rgb(255,246,239);padding:30rpx 0 20rpx 0;
			border-radius:10rpx;box-shadow: 0px 3px 4px #ddd;">
				<view style="display: flex;flex-direction: column;align-items: center;">
					<image src="../static/my/p6.png" mode="widthFix"
					style="width:58rpx;height:58rpx;">
					<view class="u-m-t-15">我的钱包</view>
				</view>
			</view>
		</view>
		<!-- 以上为服务项目、服务设置、我的钱包 -->
		<view style="margin:15rpx 30rpx 0 30rpx;border-radius: 7px;overflow: hidden;
		box-shadow: 0px 3px 4px #ddd;">
			<view class="cbg-white" style="display: flex;flex-direction: column;display: flex;
			;">
				<view style="font-weight: bold;margin:20rpx 20rpx 0 20rpx;">常用操作</view>
				<view>
					<u-grid :col="5" :border="false">
						<u-grid-item @click="goPhoto()">
							<u-icon name="/static/my/p3.png" color="#FFCC45" :size="75"></u-icon>
							<view class="grid-text" style="padding-top: 5rpx; color: #777777;font-size: 25rpx;">我的相册</view>
						</u-grid-item>
						<u-grid-item @click="goService()" >
							<u-icon name="/static/my/p1.png" color="#FFCC45" :size="75"></u-icon>
							<view class="grid-text" style="padding-top: 5rpx; color: #777777; font-size: 25rpx;">联系客服</view>
						</u-grid-item>
						<u-grid-item @click="goPingJia()" >
							<u-icon name="/static/my/p5.png" color="#FFCC45" :size="75"></u-icon>
							<view class="grid-text" style="padding-top: 5rpx; color: #777777;font-size: 25rpx;">用户评价</view>
						</u-grid-item>
						<u-grid-item @click="goRenZheng()" >
							<u-icon name="/static/my/p4.png" color="#FFCC45" :size="75"></u-icon>
							<view class="grid-text" style="padding-top: 5rpx; color: #777777;font-size: 25rpx;">身份认证</view>
						</u-grid-item>
						<u-grid-item @click="goSetting()" >
							<u-icon name="/static/my/p2.png" color="#FFCC45" :size="75"></u-icon>
							<view class="grid-text" style="padding-top: 5rpx; color: #777777;font-size: 25rpx;">应用设置</view>
						</u-grid-item>
					</u-grid>
				</view>
			</view>
		</view>
		<view v-if="userInfo.activity_photo" style="display: flex;justify-content: center;
		margin:25rpx;" @tap="goHuoDong()">
			<image mode="widthFix" :src="userInfo.activity_photo" 
			style="width:700rpx;height:240rpx;border-radius: 15rpx;"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data:null,
				isLogin: false,
				renZhenShow:false,
				userInfo: {
					photo: "../static/weiDL.png",
					name: "未登录",
					score: 0,
					jieDanLv: 0,
					sucOrder: 0,
					fans: 0,
					activity_photo:'',
					activety_url:'',
					jishiInfo:{
						avatar:''
					}
				},
			}
		},
		onLoad() {

		},
		onShow() {
			this.getInfo()
			this.timeWork()
		},
		methods: {
			getInfo(){
				let isLogin = this.$store.state.isLogin;
				this.isLogin = isLogin;
				if(isLogin == true){
					this.$request("worker/other/selectWorker").then(res=>{
						if(res.msg=="操作成功"){
							this.jishiInfo = res.data;
							this.userInfo.artAvatar = res.data.avatar;
							this.userInfo.name = res.data.name;
							this.userInfo.score = res.data.score;
							this.userInfo.jieDanLv = res.data.params.jieDanLv;
							this.userInfo.sucOrder = res.data.num;
							this.userInfo.fans = res.data.params.fans;
							this.userInfo.activity_photo = res.data.params.huoDongUrl.photo;
							this.userInfo.activety_url=res.data.params.huoDongUrl.url;
							this.$store.commit("setwId",res.data.id);
							this.$store.commit("setwName",res.data.name);
						}
						
					})
				}else {
					return
				}
				
			},	
			goLogin(){
				uni.navigateTo({
					url:'../pages/login/login'
				})
			},
			goService(){
				uni.makePhoneCall({
					phoneNumber: 15730059322
				})
			},
			goHuoDong(){
				if(!this.userInfo.activety_url){
					return;
				}else {
					uni.navigateTo({
						url:"../pagesB/my/xieyi?url="+this.userInfo.activety_url
					})
				}
			},
			goQianBao(){
				if(this.isLogin==false){
					uni.showModal({
						title:'提示',
						content:'暂未登录',
						success(res) {
							if(res.confirm){
								// 跳转到登录
								uni.reLaunch({
									url:"/pages/login/login",
									success: (res) => {
									},
									fail: (err) => {
										console.log("error=>"+JSON.stringify(err))
									}
								})
							}
						}
					})
				}else{
					uni.navigateTo({
						url:'../pagesB/my/qianbao'
					})					
				}
			},
			goFuWuSet(){
				if(this.isLogin==false){
					uni.showModal({
						title:'提示',
						content:'暂未登录',
						success(res) {
							if(res.confirm){
								// 跳转到登录
								uni.reLaunch({
									url:"/pages/login/login",
									success: (res) => {
									},
									fail: (err) => {
										console.log("error=>"+JSON.stringify(err))
									}
								})
							}
						}
					})
				}else{
					uni.switchTab({
						url:'/pages/tab1'
					})
				}
			},
			goFuWu(){
				if(this.isLogin==false){
					uni.showModal({
						title:'提示',
						content:'暂未登录',
						success(res) {
							if(res.confirm){
								// 跳转到登录
								uni.reLaunch({
									url:"/pages/login/login",
									success: (res) => {
									},
									fail: (err) => {
										console.log("error=>"+JSON.stringify(err))
									}
								})
							}
						}
					})
				}else{
					uni.reLaunch({
						url:'tab2'
					})					
				}
			},
			goPhoto(){
				if(this.isLogin==false){
					uni.showModal({
						title:'提示',
						content:'暂未登录',
						success(res) {
							if(res.confirm){
								// 跳转到登录
								uni.reLaunch({
									url:"/pages/login/login",
									success: (res) => {
									},
									fail: (err) => {
										console.log("error=>"+JSON.stringify(err))
									}
								})
							}
						}
					})
				}else{
					uni.navigateTo({
						url:'../pagesB/my/photo'
					})					
				}
			},
			goRenZheng(){
				if(this.isLogin==false){
					uni.showModal({
						title:'提示',
						content:'暂未登录',
						success(res) {
							if(res.confirm){
								// 跳转到登录
								uni.reLaunch({
									url:"/pages/login/login",
									success: (res) => {
									},
									fail: (err) => {
										console.log("error=>"+JSON.stringify(err))
									}
								})
							}
						}
					})
				}else{
					uni.navigateTo({
						url:'../pagesB/my/shenFenRenZheng'
					})					
				}
			},
			goPingJia(){
				if(this.isLogin==false){
					uni.showModal({
						title:'提示',
						content:'暂未登录',
						success(res) {
							if(res.confirm){
								// 跳转到登录
								uni.reLaunch({
									url:"/pages/login/login",
									success: (res) => {
									},
									fail: (err) => {
										console.log("error=>"+JSON.stringify(err))
									}
								})
							}
						}
					})
				}else{
					uni.navigateTo({
						url:'../pagesB/my/pingJia'
					})					
				}
			},
			timeWork() {
				let obj = {
					day: '2025-08-03'
				}
				this.$request("worker/jiedan/getFuWuTime", obj).then(res => {
					if(res.msg=='请先进行身份认证'){
						this.renZhenShow = false
					}else{
						this.renZhenShow = true
					}
					
				})
			},
			goSetting(){
				uni.navigateTo({
					url:'../pagesB/my/setting'
				})
			},
			goMyInfo(){
				if(this.isLogin==false){
					uni.showModal({
						title:'提示',
						content:'暂未登录',
						success(res) {
							if(res.confirm){
								// 跳转到登录
								uni.reLaunch({
									url:"/pages/login/login",
									success: (res) => {
									},
									fail: (err) => {
										console.log("error=>"+JSON.stringify(err))
									}
								})
							}
						}
					})
				}else {
					uni.navigateTo({
						url:'../pagesB/my/gerenxinxi'
					})
				}
			}
		},
		computed:{
			statuBarHeight(){
				// //console.log(this.$store.state.sysInfo.statusBarHeight)
				return this.$store.state.sysInfo.statusBarHeight;
			}
		},
	}
</script>

<style>
	
</style>
